﻿
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace Vehicle.DAL
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Vehicles.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-08-28    Created by 杨光远 V1.00.0000
    /// 功能说明：Vehicles表数据层类（继承于数据层基类)
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public class Vehicles : DAL.Base_DAL, Vehicle.Interface.IVehicles
    {
        /// <summary>
        /// 绑定页面Repeater控件
        /// </summary>
        /// <param name="Rept">Repeater控件</param>
        ///  <param name="m_ComponentsInfo">系统通用实体层</param>
        public void RepeaterBind(Repeater Rept, Model.ComponentsInfo m_ComponentsInfo)
        {
            Rept.DataSource = GetAllSearch(new Model.ComponentsInfo(m_ComponentsInfo.startIndex, m_ComponentsInfo.endIndex, "Vehicles", m_ComponentsInfo.condition, m_ComponentsInfo.result, m_ComponentsInfo.Tcondition, m_ComponentsInfo.Tresult, m_ComponentsInfo.Scondition, m_ComponentsInfo.Sresult, "V_Time", m_ComponentsInfo.StartTime, m_ComponentsInfo.EndTime, "V_ID")).DefaultView;
            Rept.DataBind();
        }
       /// <summary>
        /// 添加车辆信息
       /// </summary>
       /// <param name="m_VehiclesInfo">实体对象</param>
        public void Add(Model.VehiclesInfo m_VehiclesInfo)
        {
            string SpName = "Vehicles_ADD";
            object[] _object = new object[] { 0, m_VehiclesInfo.M_ID, m_VehiclesInfo.P_ID, m_VehiclesInfo.V_LicenseNum, m_VehiclesInfo.V_ProvinceCity, m_VehiclesInfo.V_Length, m_VehiclesInfo.V_Load, m_VehiclesInfo.V_Model, m_VehiclesInfo.V_Route, m_VehiclesInfo.V_Unit, m_VehiclesInfo.V_Time, m_VehiclesInfo.V_Num, m_VehiclesInfo.V_ETiem, m_VehiclesInfo.V_Transit, m_VehiclesInfo.V_Note, m_VehiclesInfo.V_LastTime, m_VehiclesInfo.V_IsDelete, m_VehiclesInfo.V_MNumber, m_VehiclesInfo.V_ReleaseDate, m_VehiclesInfo.V_BuyDate, m_VehiclesInfo.V_Fuel, m_VehiclesInfo.V_Let, m_VehiclesInfo.V_Manufacturer, m_VehiclesInfo.V_Color};
            SqlHelper.ExecuteNonQuery(SpName, _object);
        }
        /// <summary>
        /// 修改车辆信息
        /// </summary>
        /// <param name="m_VehiclesInfo">实体对象</param>
        public void Update(Model.VehiclesInfo m_VehiclesInfo)
        {
            string SpName = "Vehicles_Update";
            object[] _object = new object[] { 0,m_VehiclesInfo.V_ID, m_VehiclesInfo.M_ID, m_VehiclesInfo.P_ID, m_VehiclesInfo.V_LicenseNum, m_VehiclesInfo.V_ProvinceCity, m_VehiclesInfo.V_Length, m_VehiclesInfo.V_Load, m_VehiclesInfo.V_Model, m_VehiclesInfo.V_Route, m_VehiclesInfo.V_Unit, m_VehiclesInfo.V_Time, m_VehiclesInfo.V_Num, m_VehiclesInfo.V_ETiem, m_VehiclesInfo.V_Transit, m_VehiclesInfo.V_Note, m_VehiclesInfo.V_LastTime, m_VehiclesInfo.V_IsDelete,m_VehiclesInfo.V_MNumber,m_VehiclesInfo.V_ReleaseDate,m_VehiclesInfo.V_BuyDate,m_VehiclesInfo.V_Fuel,m_VehiclesInfo.V_Let,m_VehiclesInfo.V_Manufacturer,m_VehiclesInfo.V_Color};
            SqlHelper.ExecuteNonQuery(SpName, _object);
        }
        /// <summary>
        /// 根据车队绑定下属车辆页面DropDownList控件
        /// </summary>
        /// <param name="drop">DropDownList控件对象</param>
        /// <param name="m_ComponentsInfo">通用实体对象</param>
        public void DropDownListBind(DropDownList drop, Model.ComponentsInfo m_ComponentsInfo)
        {
            drop.DataSource = GetModel(m_ComponentsInfo).DefaultView;
            drop.DataTextField = "V_LicenseNum";//显示的名称
            drop.DataValueField = "V_ID";//数据值
            drop.DataBind();
            drop.Items.Add(new ListItem("无", "0"));
            drop.SelectedValue = "0";  //默认选择全部
        }
    }
}
